package com.my.beans;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Course {
	private String cno;
	private String ctno;
	private String term;
	private String cname;
	private String period;
	private float credit;
	private String dept;
	private String tea;
	private String place;
	private String time;

	
	public Course(String cno,String ctno, String term,String cname,String period,float credit,String dept, String tea,String place,String time) {
		super();
		this.cno=cno;
		this.ctno=ctno;
		this.cname = cname;
		this.term = term;
		this.period = period;
		this.credit=credit;
		this.dept=dept;
		this.tea = tea;
		this.place=place;
		this.time=time;
	
	}


	@Override
	public String toString() {
		return "Course [cno=" + cno + ", ctno=" + ctno +", cname=" + cname + ", term=" + term + ", period=" + period +
				", credit=" + credit +",dept=" + dept +", tea=" + tea + ", place=" + place +", time=" + time + "]";
	}
	public String getCno() {
		return cno;
	}


	public void setCno(String cno) {
		this.cno = cno;
	}
	
	public String getCtno() {
		return ctno;
	}


	public void setCtno(String ctno) {
		this.ctno = ctno;
	}


	public String getCname() {
		return cname;
	}


	public void setCname(String cname) {
		this.cname = cname;
	}


	public String getTerm() {
		return term;
	}


	public void setTerm(String term) {
		this.term = term;
	}


	public String getPeriod() {
		return period;
	}


	public void setPeriod(String period) {
		this.period = period;
	}
	
	public float getCredit() {
		return credit;
	}


	public void setCredit(float credit) {
		this.credit = credit;
	}
	public String getDno() {
		return dept;
	}


	public void setDno(String dept) {
		this.dept = dept;
	}


	public String getTno() {
		return tea;
	}
	
public String getTname(){
		
	    try {Connection con = DriverManager.getConnection(
				"jdbc:mysql://localhost:3306/educatesystem", "root", "123456");
		
	    Statement st = con.createStatement();
			ResultSet rs = st.executeQuery("select * from teacher");
			while(rs.next())
			{
				if((rs.getString("tno").equals(tea)))
				{
					return 	rs.getString("tname")	;
				}
				
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	    return "1";
	}

public String getDname(){
	
    try {Connection con = DriverManager.getConnection(
			"jdbc:mysql://localhost:3306/educatesystem", "root", "123456");
	
    Statement st = con.createStatement();
		ResultSet rs = st.executeQuery("select * from department");
		while(rs.next())
		{
			if((rs.getString("dno").equals(dept)))
			{
				return 	rs.getString("dname")	;
			}
			
		}
	} catch (SQLException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
    return "1";
}
	public void setTno(String tea) {
		this.tea = tea;
	}

	public String getPlace() {
		return place;
	}


	public void setPlace(String place) {
		this.place = place;
	}
	public String getTime() {
		return time;
	}


	public void setTime(String time) {
		this.time = time;
	}



	public Course(){}


	



}
